package com.multi.thread.chapter07.demo01;

public class MyThread03 {
	
	synchronized static public void serviceMethod() {
		System.out.println(Thread.currentThread().getName() + "进入了业务方法!");
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	static class TestThread01 extends Thread {

		@Override
		public void run() {
			MyThread03.serviceMethod();
		}
	}
	
	static class TestThread02 extends Thread {

		@Override
		public void run() {
			MyThread03.serviceMethod();
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		TestThread01 t1 = new TestThread01();
		t1.setName("a");
		t1.start();
		
		TestThread02 t2 = new TestThread02();
		t2.setName("b");
		t2.start();
		System.out.println("mian方法中的t2状态：" + t2.getState());
	}

}
